import { Body, Controller, Get, Post } from '@nestjs/common';
import { ApiOperation, ApiTags } from '@nestjs/swagger';
import { GoodsService } from '../services/goods.services';
import { ResponseUtils } from 'src/common/utils/response.utils';
import { GoodsAddDTO } from '../dto/goodsAdd.dto';

@Controller('api/goods')
@ApiTags('商品模块')
export class GoodsController {
  constructor(private readonly goodsService: GoodsService) {}

  @Get('/list')
  @ApiOperation({ summary: '商品列表' })
  async getList() {
    const goodsList = await this.goodsService.getAllGoods();
    return ResponseUtils.success(goodsList);
  }

  @Post('/add')
  @ApiOperation({ summary: '商品新增' })
  async add(@Body() goodsAddDTO: GoodsAddDTO) {
    await this.goodsService.addGoods(goodsAddDTO);
    return ResponseUtils.success(null, '商品添加成功');
  }
}
